package com.example.administrator.tenyuanpackage.home.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.example.administrator.tenyuanpackage.R;
import com.example.administrator.tenyuanpackage.home.bean.PreferentialBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static android.content.ContentValues.TAG;

/**
 * Created by zwq on 2017/2/27.
 */

public class HomePreferential extends LinearLayout {

    @BindView(R.id.pre_zuixin)
    ImageView preZuixin;
    @BindView(R.id.pre_zhoubian)
    ImageView preZhoubian;
    @BindView(R.id.pre_meizhuang)
    ImageView preMeizhuang;
    @BindView(R.id.pre_food)
    ImageView preFood;
    @BindView(R.id.pre_end)
    ImageView preEnd;
    private ArrayList<PreferentialBean> preferentials = new ArrayList<>();
    public HomePreferential(Context context) {
        super(context);
        init();
    }

    public HomePreferential(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext())
                .inflate(R.layout.home_preferential, this, true);
        ButterKnife.bind(this, this);

    }

    public void setPreferentialData(ArrayList<PreferentialBean> preferentials){
        Log.i(TAG, "setPreferentialData:===================== "+preferentials.size());
        Glide.with(getContext()).load(preferentials.get(0).getImgUrl()).into(preZuixin);
        Glide.with(getContext()).load(preferentials.get(1).getImgUrl()).into(preZhoubian);
        Glide.with(getContext()).load(preferentials.get(2).getImgUrl()).into(preFood);
        Glide.with(getContext()).load(preferentials.get(3).getImgUrl()).into(preMeizhuang);
        Glide.with(getContext()).load(preferentials.get(4).getImgUrl()).into(preEnd);
    }

    @OnClick({R.id.pre_zuixin, R.id.pre_zhoubian, R.id.pre_meizhuang, R.id.pre_food, R.id.pre_end})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.pre_zuixin:
                break;
            case R.id.pre_zhoubian:
                break;
            case R.id.pre_meizhuang:
                break;
            case R.id.pre_food:
                break;
            case R.id.pre_end:
                break;
        }
    }
}
